package com.example.task1.ui.AllService.PublicBenefit;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.application.MyApplication;
import com.example.task1.bean.AllServiceBean;
import com.example.task1.bean.PublicSortBean;
import com.example.task1.ui.BaseAdapter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class PublicSortAdapter extends BaseAdapter<PublicSortBean.DataDTO> {

    private Context context;
    private List<PublicSortBean.DataDTO> mData;
    private ImageView ivImage;
    private TextView title;

    public PublicSortAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected void setData(List<PublicSortBean.DataDTO> data) {
        this.mData = data;
    }

    @Override
    protected int getLayout() {
        return R.layout.base_service;
    }

    @Override
    protected Context getContext() {
        return null;
    }

    @Override
    protected List<PublicSortBean.DataDTO> getData() {
        return mData;
    }

    @Override
    protected void onBind(myHolder holder, PublicSortBean.DataDTO date) {
        MyApplication.glide(ivImage, date.getImgUrl());
        title.setText(date.getName());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, SortDetailsActivity.class);
                intent.putExtra("id", date.getId());
                context.startActivity(intent);
            }
        });
    }

    @Override
    protected void holder(View itemView) {
        initView(itemView);
    }

    private void initView(View itemView) {
        ivImage = itemView.findViewById(R.id.iv_image);
        title = itemView.findViewById(R.id.title);
    }
}
